package com.zhuiyun.project.api.search.controller;

import com.zhuiyun.project.api.search.service.SearchService;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName SearchController
 * @Description TODO 前端用户搜索界面
 * @Author YYR
 * @Date 2024/3/15 16:19
 **/
@RestController
@RequestMapping("/search")
@Api(tags = "前端用户搜索界面")
public class SearchController {
    @Autowired
    private SearchService searchService;

    /**
    * @Author YYR
    * @Description 将视频以热度为条件进行榜单排行并展示
    * @Date 2024/3/15 16:56
    * @Return com.zhuiyun.project.common.response.CommonResult
    */

    @GetMapping("/getVideoByHot")
    @ApiOperation(value = "将视频以热度为条件进行榜单排行并展示")
    public CommonResult getVideoByHot() throws CommonException {
        return CommonResult.ok(searchService.getVideoByHot());
    }
    /**
    * @Author YYR
    * @Description 关键字查询
    * @Date 2024/3/18 16:05
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param keyword
     *
    */

    @GetMapping("/getFuzzyQuery")
    @ApiOperation(value = "关键字查询")
    public CommonResult getFuzzyQuery(@RequestParam String keyword){
        return CommonResult.ok(searchService.getFuzzyQuery(keyword));
    }
}
